{{define "infoCollection/ecg.html"}}
<div class="box box-info">
    <div class="box-header with-border">
        <h3 class="box-title">心电图</h3>
    </div>
    <form class="form-horizontal" id="ecgForm">
        <div class="box-body">
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    检查人：
                </label>
                <div class="col-sm-2">
                    <input type="text" name="ecgDoctor" id="ecgDoctor" class="form-control" placeholder="检查人">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    检查时间：
                </label>
                <div class="col-sm-2">
                    <div class="input-group date">
                        <div class="input-group-addon">
                            <i class="fa fa-calendar"></i>
                        </div>
                        <input type="text" name="ecgExamineDate" id="ecgExamineDate" class="form-control pull-right">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2">检查结果：</label>
                <div class="radio col-sm-2">
                    <input type="radio" name="ecgResult" value="正常" class="minimal" checked>&nbsp;&nbsp;正常&nbsp;&nbsp;
                    <input type="radio" name="ecgResult" value="异常" class="minimal">&nbsp;&nbsp;异常
                </div>
            </div>
            <div class="form-group" id="ecgResult_abnormal" style="display: none">
                <label class="control-label col-sm-2">
                    <span  style="color: red;font-weight: bold;">异常类型：</span>
                </label>
                <div class="radio col-sm-2">
                    <input type="radio" name="ecgResult_abnormal_type" value="房颤" class="minimal">&nbsp;&nbsp;房颤&nbsp;&nbsp;
                    <input type="radio" name="ecgResult_abnormal_type" value="其他类型" class="minimal">&nbsp;&nbsp;其他类型
                </div>
            </div>
        </div>
        <div class="box-footer">
            <button type="button" class="btn btn-info btn-lg middleBtn" id="saveEcg">保存</button>
        </div>
    </form>

</div>
<script>
    if (canUpdate != null && canUpdate != undefined && !canUpdate) {
        $("#saveEcg").hide();
    }
    $("input:radio[name='ecgResult']").on('ifChanged', function (event) {
        if ($(this).is(':checked')) {
            if ($(this).val() == "异常") {
                $("#ecgResult_abnormal").show();
            } else {
                $("#ecgResult_abnormal").hide();
                $("input:radio[name='ecgResult_abnormal_type']").iCheck('uncheck');
            }
        }
    });


    $("#saveEcg").click(function () {
        let d = {};
        let t = $('#ecgForm').serializeArray();
        $.each(t, function () {
            d[this.name] = this.value;
        });
        let data = JSON.stringify(d);
        ajaxLoading("正在提交数据...");
        $.post("/infoCollection/save", {type: "ecg", id: $("#screenId").val(), data: data}, function (resp) {
            ajaxLoadEnd();
            afterUpdateFormData(resp,"ecg");
        });
    });

    function ecgInit(ecgData) {
        $("#ecgForm").initForm({jsonValue: ecgData, isDebug: false});
    }

</script>
{{end}}